/**
 * Project: complex.cs
 * 
 * File Created at 2010-7-1
 * $Id$
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package mina;

import java.net.InetSocketAddress;

import org.apache.mina.common.DefaultIoFilterChainBuilder;
import org.apache.mina.filter.codec.ProtocolCodecFilter;
import org.apache.mina.filter.codec.textline.TextLineCodecFactory;
import org.apache.mina.transport.socket.nio.SocketAcceptor;

/**
 * 简单Mina Server示例
 */
public class MainServer {
    public static void main(String[] args) throws Exception {
        //创建一个非阻塞的Server端Socket
        SocketAcceptor acceptor = new SocketAcceptor();
        //创建接收数据的过滤器
        DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
        //设定这个过滤器将一行一行(/r/n)的读取数据
        chain.addLast("myChin", new ProtocolCodecFilter(new TextLineCodecFactory()));
        //绑定端口,启动服务器
        acceptor.bind(new InetSocketAddress(9988), new SamplMinaServerHandler(), null);
        System.out.println("Mina Server is Listing on:= " + 9988);
    }
}
